package com.zhihuichongcheng.application.ui.im.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zhihuichongcheng.application.R;
import com.zhihuichongcheng.application.bean.mine.UserBean;
import com.zhihuichongcheng.application.glide.GlideCircleTransform;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 3water on 2016/10/27.
 */

public class GroupSelectAdapter extends RecyclerView.Adapter<GroupSelectAdapter.ViewHold> {
    private List<UserBean> mListData = new ArrayList<>();
    private Context mContext;

    public GroupSelectAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public ViewHold onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.listadapter_select_group, null);
        return new ViewHold(view);
    }

    @Override
    public void onBindViewHolder(ViewHold holder, int position) {
        UserBean bean = mListData.get(position);
        Glide.with(mContext).load(bean.getLogoUrl()).placeholder(R.drawable.ic_default_avatar).transform(new GlideCircleTransform(mContext)).into(holder.mImAvatar);
        holder.userName.setText(bean.getUserName());
    }

    @Override
    public int getItemCount() {
        return mListData.size();
    }

    public void setData(List<UserBean> list) {
        mListData = list;
//        mListData.add(userBean);
    }

    class ViewHold extends RecyclerView.ViewHolder {
        private ImageView mImAvatar;
        private TextView userName;

        public ViewHold(View itemView) {
            super(itemView);
            mImAvatar = (ImageView) itemView.findViewById(R.id.im_avatar);
            userName = (TextView) itemView.findViewById(R.id.user_name);

        }
    }

}
